package hydrap2p.logging;

import hydrap2p.ServiceLocation;

/**
 * Small helper class to encapsulate a service location and a severity level plus an equals() override.
 * 
 * @author cavanagj
 */
public class LoggingSubscriber {
	ServiceLocation location;
	Level minimumSeverity;
	LoggingListener.Client connection;
	
	public LoggingSubscriber(ServiceLocation location, Level minimumSeverity2) {
		this.location = location;
		this.minimumSeverity = minimumSeverity2;
	}
	
	public ServiceLocation getLocation() {
		return location;
	}

	public void setLocation(ServiceLocation location) {
		this.location = location;
	}

	public Level getMinimumSeverity() {
		return minimumSeverity;
	}

	public void setMinimumSeverity(Level minimumSeverity) {
		this.minimumSeverity = minimumSeverity;
	}
	
	public LoggingListener.Client getConnection() {
		return connection;
	}

	public void setConnection(LoggingListener.Client connection) {
		this.connection = connection;
	}

	@Override
	public boolean equals(Object obj) {
		if(obj instanceof LoggingSubscriber) {
			LoggingSubscriber service = (LoggingSubscriber)obj;
			
			if(this.location.equals(service.getLocation()))
				return true;
		}
		
		return false;
	}
}
